package ThreadTest;

public class TestDemo4 {
    public static void main(String[] args) {
        Object object = new Object();//实例化一个Object类对象
        Thread thread = new Thread(()->{
            synchronized (object) {
                try {
                    object.wait(2000);//thread调用了带参wait方法，停顿了两秒
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("Hello thread");
            }
        });//创建thread线程
        thread.start();//启动thread线程

        synchronized (object) {
            object.notify();//main方法内调用notify方法
        }
        System.out.println("Hello main");
    }
}
